package com.wxapp.pay.service.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wxapp.common.constant.base.IBaseController;
import com.wxapp.common.constant.pojo.vm.ResultVm;
import com.wxapp.common.constant.pojo.vo.UserVo;
import com.wxapp.common.core.annotation.User;
import com.wxapp.pay.api.pojo.pojo.vm.pay.PPayDetailVm;
import com.wxapp.pay.api.pojo.pojo.vm.pay.PPayPageVm;
import com.wxapp.pay.api.pojo.pojo.vm.pay.PPaySelectVm;
import com.wxapp.pay.api.pojo.pojo.vo.pay.QPayAddVo;
import com.wxapp.pay.api.pojo.pojo.vo.pay.QPayPageVo;
import com.wxapp.pay.api.pojo.pojo.vo.pay.QPayUpdateVo;
import com.wxapp.pay.service.service.PayService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author lgl
 */
@RestController
@Tag(name = "支付")
@RequestMapping("pay")
@RequiredArgsConstructor
public class PayController extends IBaseController {
    private final PayService payService;

    @PostMapping("add")
    @Operation(summary = "添加支付方式")
    public ResultVm<String> add(@RequestBody @Validated QPayAddVo qPayAddVo, @Schema(hidden = true) @User UserVo userVo) {
        return payService.add(qPayAddVo, userVo);
    }

    @PutMapping("update")
    @Operation(summary = "更新支付方式")
    public ResultVm<String> update(@RequestBody @Validated QPayUpdateVo qPayUpdateVo, @Schema(hidden = true) @User UserVo userVo) {
        return payService.update(qPayUpdateVo, userVo);
    }

    @PostMapping("page")
    @Operation(summary = "获取支付方式列表")
    public ResultVm<Page<PPayPageVm>> page(@RequestBody QPayPageVo qPayPageVo) {
        return payService.page(qPayPageVo);
    }

    @DeleteMapping("delete/{id}")
    @Operation(summary = "删除支付方式")
    public ResultVm<String> delGoods(@PathVariable String id) {
        return payService.delGoods(id);
    }

    @GetMapping("/detail/{id}")
    @Operation(summary = "获取支付方式详细信息")
    public ResultVm<PPayDetailVm> detail(@PathVariable String id) {
        return payService.detail(id);
    }

    @GetMapping("/getPaySelect")
    @Operation(summary = "获取支付下拉框")
    public ResultVm<List<PPaySelectVm>> getPaySelect() {
        return payService.getPaySelect();
    }
}
